﻿
using Admin.NET.Core.Service;
namespace Admin.NET.Application.Service;

/// <summary>
/// 配置菜单对象映射
/// </summary>
public class SysMenuMapper : IRegister
{
    public void Register(TypeAdapterConfig config)
    {
        //
        config.ForType<MenuOutput, LayUIMenuOutput>()
            .Map(dest => dest.Title, src => src.Meta.Title)
            .Map(dest => dest.Icon, src => src.Meta.Icon)
            .Map(dest => dest.Href, src => src.Path)
            .Map(dest => dest.OpenType, src => string.IsNullOrWhiteSpace(src.Remark) ? "_iframe" : src.Remark);
        //
        config.ForType<SysMenu, MenuExOutput>()
           .Map(dest => dest.Title, src => src.Name)
           .Map(dest => dest.Name, src => src.Title);

        //
        config.ForType<SysMenu, TreeSelectDto>()
           .Map(dest => dest.Name, src => src.Title);
    }
}